<template>
  <view class="container">
    <!-- 仅保留头像和名字 -->
    <view class="user-info">
      <image src="/static/images/user.png" class="avatar"></image>
      <text class="user-name">{{userInfo.username}}</text> <!-- 可替换为动态用户名 -->
    </view>

    <!-- 仅保留“我的订单”菜单 -->
    <view class="menu-list">
      <view class="menu-item" @click="navigateToOrderList">
        <image src="/static/icon/mybooking.png" class="menu-icon"></image>
        <text class="menu-text">我的订单</text>
        <image src="/static/icon/arrow.png" class="menu-arrow"></image>
      </view>
    </view>
	
    <!-- 订单核销入口（仅管理员可见） -->
    <view class="menu-list" v-if="isAdmin">
      <view class="menu-item" @click="navigateToVerificationList">
        <image src="/static/icon/mybooking.png" class="menu-icon"></image>
        <text class="menu-text">订单核销</text>
        <image src="/static/icon/arrow.png" class="menu-arrow"></image>
      </view>
    </view>
  </view>
</template>

<script setup>
	import {
		ref,
		computed
	} from 'vue'
	const userInfo = ref({
	  avatarUrl: '/static/image/default_avatar.png',
	  username: '黄庆龙'
	});
	
	// 获取用户信息
	const initUserInfo = () => {
	  try {
	    const userConfig = uni.getStorageSync('userConfig');
	    console.log('用户配置信息', userConfig);
	    if (userConfig) {
	      userInfo.value = {
	        ...userInfo.value,
	        ...userConfig,
			username:userConfig.nickName
	      };
	    }
	  } catch (error) {
	    console.error('获取用户信息失败', error);
	  }
	};
	
	// 初始化用户信息
	initUserInfo();
	
	// 模拟管理员身份（实际项目中应从用户信息中获取）
	const isAdmin = computed(() => {
	  // 简单模拟：用户名包含"管理员"字样即为管理员
	  // return userInfo.value.username.includes('管理员') || userInfo.value.username === 'admin';
    return true
	});

	
const navigateToOrderList = () => {
		uni.navigateTo({
			url: '/pages/mine/orderList'
		})
	}
	
	// 跳转到核销列表页面
	const navigateToVerificationList = () => {
		uni.navigateTo({
			url: '/pages/mine/verificationList'
		})
	}
</script>

<style scoped>
.container {
  background-color: #f5f5f5;
  min-height: 100vh;
}

/* 用户信息区域（仅头像+名字） */
.user-info {
  background: linear-gradient(135deg, #FF4D00, #FF8A00);
  padding: 60rpx 30rpx;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.avatar {
  width: 160rpx;
  height: 160rpx;
  border-radius: 80rpx;
  background: #fff;
  margin-bottom: 20rpx;
}

.user-name {
  color: #fff;
  font-size: 32rpx;
  font-weight: bold;
}

/* 仅保留“我的订单”菜单 */
.menu-list {
  background: #fff;
  margin: 20rpx;
  border-radius: 16rpx;
}

.menu-item {
  display: flex;
  align-items: center;
  padding: 30rpx;
}

.menu-icon {
  width: 50rpx;
  height: 50rpx;
  margin-right: 30rpx;
}

.menu-text {
  font-size: 28rpx;
  color: #333;
  flex: 1;
}

.menu-arrow {
  width: 30rpx;
  height: 30rpx;
  opacity: 0.5;
}
</style>